#include <stdio.h>
#include <stdlib.h>

struct node {
	int data;
	struct node *next;
};

void push(struct node **, int);

void main(void) {
	struct node *head = NULL;
	int i;

	push(&head, 0);

	struct node *test;
	test = head;

	for (i = 1; i < 10; i ++) {
		push(&(head->next), i);
		head = head->next;
	}


	struct node *current = NULL;
	struct node *iter;
	
	while(test != NULL) {
		if (current == NULL) {
			current = malloc(sizeof(struct node));
			current->data = test->data;
			current->next = NULL;
			iter = current;
		} else {
			current->next = malloc(sizeof(struct node));
			current = current->next;
			current->data = test->data;
			current->next = NULL;
		}
		test = test->next;
	}

	for ( i = 1; i < 10; i ++) {
		printf("%d ", iter->data);
		iter = iter->next;
	}
	printf("\n");
}

void push(struct node **ref, int data) {
	struct node *new_node = malloc(sizeof(struct node));

	new_node->data = data;
	*ref = new_node;
}
